package gosnoopers.fr;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;



@SuppressWarnings("deprecation")
public class InscriptionActivity extends TabActivity implements OnTabChangeListener {

	TabHost tabHost;
	TextView text;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.inscription);
		text = (TextView) findViewById(R.id.text_view_landing_page_header);
		text.setText("Information");
		
		tabHost = getTabHost();  
   
        TabSpec info = tabHost.newTabSpec("Info");  
        info.setIndicator("Information");
        Intent infoIntent = new Intent(this, InscriptionInfoActivity.class);
        info.setContent(infoIntent);
         
        TabSpec avatar = tabHost.newTabSpec("Avatar");        
        avatar.setIndicator("Logo");
        Intent avatarIntent = new Intent(this, InscriptionAvatarActivity.class);
        avatar.setContent(avatarIntent);
        
        tabHost.addTab(info);
        tabHost.addTab(avatar);
        tabHost.setOnTabChangedListener(this);
        
        
        
        ImageView btn_setting = (ImageView) findViewById(R.id.image_setting);
		btn_setting.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent goToNextActivity = new Intent(getApplicationContext(), Settings.class);
	            startActivity(goToNextActivity);
			}
		});
		
		/**
		 * Kiem user da dang nhap hay chua
		 * 1. hein thi icon user
		 * 2. hien thi icon add victimes
		 */
		ImageView image_open_left_navigation = (ImageView) findViewById(R.id.image_open_left_navigation);
		ImageView icon_header_form = (ImageView) findViewById(R.id.icon_header_form);
		if(MainActivity.userId.equalsIgnoreCase("0")){
			image_open_left_navigation.setVisibility(View.VISIBLE);
			icon_header_form.setVisibility(View.GONE);
		}else{
			image_open_left_navigation.setVisibility(View.GONE);
			icon_header_form.setVisibility(View.VISIBLE);
		}
		
		image_open_left_navigation.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent goToNextActivity = new Intent(getApplicationContext(), MainActivity.class);
	            startActivity(goToNextActivity);
			}
		});
		
		icon_header_form.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent goToNextActivity = new Intent(getApplicationContext(), FormFirst.class);
	            startActivity(goToNextActivity);
			}
		});
	}

	@Override
	public void onTabChanged(String arg0) {
		// TODO Auto-generated method stub
		/************ Called when tab changed *************/
        
        //********* Check current selected tab and change according images *******/
                
        Log.i("tabs", "CurrentTab: "+tabHost.getCurrentTab());
        String TextHeader = "Information";
        if(tabHost.getCurrentTab() == 0){
        	TextHeader = "Information";
        }
        if(tabHost.getCurrentTab() == 1){
        	TextHeader = "Logo";
        }
        
        text.setText(TextHeader);
	}
}
